package com.example.flshtarvel.mapper;

import com.example.flshtarvel.entity.Collect;
import com.example.flshtarvel.entity.Like;
import com.example.flshtarvel.entity.RouteLikeMap;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LikeMapper {
    //点赞
    @Insert("insert into love (message_id,message_name,article_type_id,user_id) values(#{messageId},#{messageName},#{articleTypeId},#{userId})")
    public int Like(Like like);

    //取消点赞
    @Delete("delete from love where message_id=#{messageId} and user_id=#{userId}")
    public int deleteLike(String messageId,String userId);

    //查询点赞    根据路线id 用户id
    @Select("select * from love where message_id=#{messageId} and user_id=#{userId}")
    public List<Like> selectLikeByMessageIdAndUserId(String messageId, String userId);

    //查询点赞数   根据路线id
    @Select("select count(*) from love where message_id=#{messageId}")
    public int selectLikeByMessageId(String messageId);

    //查询收藏 根据用户id
    @Select("select * from love where love.user_id = #{userId} ")
    public List<Like> selectLikeByUserId(String userId);

}
